<template>
  <div class="coBox7">
    <tiny-container :aside-width="asideWidth">
      <template #header>
        <tiny-layout>
          <CommonHeader />
        </tiny-layout>
      </template>
      <template #aside>
        <tiny-layout>
          <tiny-tree-menu
              accordion
              node-key="id"
              v-if="existFlag"
              ellipsis
              :data="resourceData"
              :default-expanded-keys="expandeArr"
              @current-change="currentChange"
          >
          </tiny-tree-menu>
        </tiny-layout>
      </template>
      <tiny-layout>
        <router-view />
      </tiny-layout>
    </tiny-container>
  </div>
</template>

<script setup>
import {Container as TinyContainer, Layout as TinyLayout, Modal, TreeMenu as TinyTreeMenu} from '@opentiny/vue'
import CommonHeader from "../components/CommonHeader.vue";
import {useAsideStore} from "../store/useAsideStore.js";
import {storeToRefs} from "pinia";
import request from "../utils/request.js";
import {useResourceStore} from "../store/useResourceStore.js";


const resourceStore = useResourceStore()
const {resourceList} = storeToRefs(resourceStore)
const asideStore = useAsideStore()
const {existFlag,asideWidth,resourceData,expandeArr} = storeToRefs(asideStore)
asideStore.queryResourceMenuData()


// 选中节点
const currentChange = (data) => {
  if (!data.children){
    // 选择子节点
    request.get(`/api/systems/files/list/${data.id}`).then(res => {
      if (res.code === 1){
        resourceList.value = res.data
      }else {
        Modal.message({message: res.message, status: 'error'})
      }
    })
  }
}
const tmp = {
  id:551
}
currentChange(tmp)

</script>

<style scoped>

</style>
